﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using HttpAssiant.Wrapper;
using HttpAssiant.BLL;
using Newtonsoft.Json.Linq;

namespace HttpAssiant
{
    public partial class Form1 : Form
    {
        JFBLL jfBll = null;

        string sid;

        public Form1()
        {
            InitializeComponent();
        }

        private void btnVisit_Click(object sender, EventArgs e)
        {
            string str = jfBll.Get_LoginUrl();
            txtHTML.AppendText(str);
        }

        private void btnPost_Click(object sender, EventArgs e)
        {
            string str = jfBll.Post_IsUserLogin(true);
            txtHTML.AppendText(str);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            System.Net.ServicePointManager.DefaultConnectionLimit = 512;

            sid = Guid.NewGuid().ToString();
            
            jfBll = new JFBLL("15136173912", "121314", sid);


        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = jfBll.Post_LOGIN();
            txtHTML.AppendText(str);
            //h1.Download("http://218.206.244.202:38080/ydzjcbb/images/login/erweima.png", imgPath, "00.jpg", "");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string str = jfBll.Get_PRODUCTURL();
            txtHTML.AppendText(str);

        }

        private void btnISLOGINBEFOR_Click(object sender, EventArgs e)
        {
            string str = jfBll.Post_ISLOGINBEFOR();
            txtHTML.AppendText(str);
        }

        private void btnDown_Click(object sender, EventArgs e)
        {
            bool suc = jfBll.Down_IMAGERAND();
            txtHTML.AppendText(suc.ToString());
        }

        private void btnRec_Click(object sender, EventArgs e)
        {
            string str = jfBll.RecognizeRadon();
            txtHTML.AppendText(str);
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            string str = jfBll.Post_PRO_GETLESSSTORAGE();
            txtHTML.AppendText(str);
            
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            string str = jfBll.Post_PRO_GETWAREDESCVALUE();
            txtHTML.AppendText(str);
            
        }

        private void btnCHECKUSER_Click(object sender, EventArgs e)
        {
            string str = jfBll.Post_CHECKUSER();
            txtHTML.AppendText(str);
        }

        private void button2_Click_2(object sender, EventArgs e)
        {
            string isLoginUser = "{\"status\":\"USER_LOGIN_STATUS_LOGIN\",\"localCount\":\"N\",\"flagIntegralDetail\":true,\"sum\":\"3\",\"info\":{\"provCode\":\"ha\",\"mobileBrand\":\"2\",\"mobileLevel\":\"100\",\"starLevelName\":\"\",\"totalPoint\":\"0\",\"mobileNumber\":\"15136173912\",\"userCurrentIntegral\":\"979\",\"loginFailNum\":0,\"memcacheKey\":\"f9f2fde67db3d6d62272287f7d49de1a\"}}";
            JObject userJsonObj = JObject.Parse(isLoginUser);

            if (userJsonObj.Property("info")!=null)
            {
                JObject userInfo = (JObject)userJsonObj["info"];
                int userCurrentIntegral = Convert.ToInt32(userInfo["userCurrentIntegral"]);
                string memcacheKey = userInfo["memcacheKey"].ToString();

                MessageBox.Show(string.Format("userCurrentIntegral:{0}, memcacheKey:{1}", userCurrentIntegral, memcacheKey));
                
            }
            
        
        }

        private void btnPost_SAVEASSIGNEEINFOS_Click(object sender, EventArgs e)
        {
            string str = jfBll.Post_SAVEASSIGNEEINFOS();
            txtHTML.AppendText(str);
            
        }

        private void btnGETASSIGNEEINFO_Click(object sender, EventArgs e)
        {
            string str = jfBll.Get_GETASSIGNEEINFO();
            txtHTML.AppendText(str);
            
        }

        private void btnSENDTRANSFERCONFIRMCODE_Click(object sender, EventArgs e)
        {
            string str = jfBll.Post_SENDTRANSFERCONFIRMCODE();
            txtHTML.AppendText(str);
            
        }

        private void button7_Click(object sender, EventArgs e)
        {
            string cc = txtCC.Text.Trim();

            string str = jfBll.Post_TRANSFERPOINTS(cc, 100);
            txtHTML.AppendText(str);
        }
    }
}
